#include "httplib.h"
#include <iostream>
int main()
{
    httplib::Server server;
    server.Get("/gain",[](const httplib::Request& req,httplib::Response& rep)->void{
        rep.set_content("hello world","text/plain");
        rep.status=200;
    });
    server.Get(R"(/num/(\d+))",[](const httplib::Request& req,httplib::Response& rep)->void{
            auto num=req.matches[1];//0下标保存的是完整URL,往后下标中保存的是捕捉的数据
        rep.set_content(num,"text/plain");
        rep.status=200;
        std::cout<<req.path<<std::endl;
    });
    server.Post("/upload",[](const httplib::Request& req,httplib::Response& rep)->void{
        int sz=req.files.size();
        auto ret=req.has_file("landscape");
        if(!ret)
        {
            rep.status=404;
            std::cout<<"Not found";
        }
    const auto& info=req.get_file_value("landscape");
        std::cout<<info.filename<<std::endl;
        std::cout<<info.content<<std::endl;
        rep.status=200;
        rep.set_content(info.content,info.content_type);
    });
    server.listen("0.0.0.0",9090);






    return 0;
}
